#ifndef NRPSTG_SCENEMODEL_H
#define	NRPSTG_SCENEMODEL_H


#include "common.h"

class Server;
class Cell;
class Block;
class TerrainDefinition;


const UNIT WORLD_X[6] = {1,-1,0,0,0,0};
const UNIT WORLD_Y[6] = {0,0,1,-1,0,0};
const UNIT WORLD_Z[6] = {0,0,0,0,1,-1};

class SceneModel {
public:

    SceneModel();
    virtual ~SceneModel();

    void set_root(UNIT* new_coord_root);
    void load(); //Generate the requests for what needs to be loaded
    void add_block_to_scene(UNIT* coord, UNIT coord_depth, Block* block);//Call back method

    TerrainDefinition* get_terrain_def(int id);

    Cell* get_cell(UNIT* coord, UNIT coord_depth);

    Cell* roots[WORLD_DEPTH];

    void const get_root_coord(UNIT* copy);
    int   const get_version();
    void  print_status();

private:
    UNIT _root_coord[3*WORLD_DEPTH];

    Server* _server;

    int _first;
    int _version;

    int _pallet_size;
    TerrainDefinition** _terrain_pallet;

    void _load(UNIT* coord, UNIT coord_depth, UNIT lod);

    bool _is_root(UNIT* coord, UNIT coord_depth);

    void _normalise_coord(UNIT* coord, UNIT* newCoord, UNIT coord_depth);

};
extern SceneModel* primary_model;

#endif	/* NRPSTG_SCENEMODEL_H */

